package com.xyht.sca_s.student_manage_system.modules.user.controller;

import com.xyht.sca_s.student_manage_system.common.annotation.RepeatRequestCheck;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.user.entity.req.SmsApplicationReq;
import com.xyht.sca_s.student_manage_system.modules.user.entity.req.SmsResourceAddReq;
import com.xyht.sca_s.student_manage_system.modules.user.entity.req.SmsResourceReq;
import com.xyht.sca_s.student_manage_system.modules.user.service.AuthorizationService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/auth")
@SecretBody
public class AuthorizationController {
        @Autowired
    private AuthorizationService authorizationService;

    @ApiModelProperty(value = "开关应用界面权限")
    @PostMapping("/updateApp")
    @RepeatRequestCheck(name = "updateApplication")
    public ResponseResult updateApplication (@RequestBody SmsApplicationReq smsApplicationReq) {
        return authorizationService.updateApplication(smsApplicationReq);
    }

    @ApiModelProperty(value = "开关资源权限")
    @PostMapping("/updateRes")
    @RepeatRequestCheck(name = "updateResourceAuthorization")
    public ResponseResult updateResourceAuthorization (@RequestBody SmsResourceReq smsResourceReq) {
        return authorizationService.updateResourceAuthorization(smsResourceReq);
    }

    @ApiModelProperty(value = "获取角色列表")
    @GetMapping("/get/roleList")
    public ResponseResult getPersonInfo () {
        return authorizationService.getRoleList();
    }

    @ApiModelProperty(value = "获取权限列表")
    @GetMapping("/get/authList")
    public ResponseResult getAuthList (@RequestParam("roleId") String roleId ,
                                       @RequestParam("clientFlag")Integer clientFlag) {
        return authorizationService.getAuthList(roleId, clientFlag);
    }

    @ApiModelProperty(value = "资源添加")
    @PostMapping("/addRes")
    public ResponseResult addResource (@RequestBody SmsResourceAddReq smsResourceAddReq) {
        return authorizationService.addResource(smsResourceAddReq);
    }



}
